import 'package:dio/dio.dart';
import 'http_tool.dart';
import '../../app_files.dart';
import 'dart:io';
import 'package:date_format/date_format.dart';

typedef void CommonCompletion(Map a);

class ResultData {
  var data;
  bool success;
  int code;
  String desc;

  ResultData(this.data, this.success, this.code, this.desc);
}

class CommonNetWork {
  static userLogin(
      {userName: '', password: '', platForm: NetworkConfig.hostUrl}) async {
    Map pamars = Map();
    pamars['UserName'] = userName;
    pamars['Password'] = password;
    pamars['PlatFormHost'] = platForm;
    pamars['Agent'] = 'APP ${Platform.isAndroid ? 'Android' : 'iOS'}';
    var res = await httpTool.netFetch('Patrol/logon', pamars);
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getImageConfig({token}) async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 10;
    pamars['PageIndex'] = 1;
    Map<String, dynamic> params = Map();
    params['ConfigKey'] = '图片保存和访问';
    pamars['Params'] = params;

    var res = await httpTool.netFetch(
      'sysconfig/list',
      pamars,
      header: token != null ? {'access-token': token} : null,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static gasUserLogin(String mobile, String password) async {
    Map<String, dynamic> pamars = Map();
    pamars['AppUserPwd'] = password;
    pamars['AppUserMobile'] = mobile;
    pamars['Agent'] = 'APP ${Platform.isAndroid ? 'Android' : 'iOS'}';
    var res = await httpTool.netFetch(
      'appuser/logon',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///个人中心
  static gasUserCenterInfo({
    token,
    String memberID,
  }) async {
    var res = await httpTool.netFetch(
      'appuser/user_info?userId=$memberID',
      null,
      header: token != null ? {'access-token': token} : null,
      method: 'Get',
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///个人中心
  static userCenterInfo({
    token,
    String memberID,
  }) async {
    Map pamars = Map();
    var res = await httpTool.netFetch(
      'Patrol/info?userId=$memberID',
      pamars,
      header: token != null ? {'access-token': token} : null,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///上传图片
  static uploadImg(
    File imgFile, {
    String fileName,
  }) async {
    String uploadUrl;
    if (GlobalStore.store.getState().uploadUrl.isEmpty)
      uploadUrl = NetworkConfig.upLoadUrl;
    else
      uploadUrl = GlobalStore.store.getState().uploadUrl;
    if (uploadUrl.endsWith('/'))
      uploadUrl = uploadUrl + 'api/home/upload';
    else
      uploadUrl = uploadUrl + '/' + 'api/home/upload';

    var res = await httpTool.formData(uploadUrl, imgFile,
        fileName: fileName,
        header: {'Token': 'oeFLNx24ySta6je6XF6HUFE9GojQYymZhYeezHpJUW8='});
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "上传成功！");
    }
  }

  static uploadImgSteam(
    List<int> fileSteam, {
    String userNo,
  }) async {
    DateTime dateTime = DateTime.now();
    String timeStr = formatDate(
        dateTime, [yyyy, '', mm, '', dd, '', HH, '', nn, '', ss, '', SSS]);
    String fileName = '${userNo}_$timeStr.jpg';
    var res = await httpTool.formSteam('securitycheck/updateImage', fileSteam,
        fileName: fileName);
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "上传成功！");
    }
  }

  ///上传图片组
  static Future<List<String>> multiUploadImgs(List images,
      {String userNo}) async {
    List<String> _list = [];
    int index = 1;
    for (var img in images) {
      if (img.runtimeType.toString() == '_File') {
        String fileName;
        if (userNo != null) {
          DateTime dateTime = DateTime.now();

          String timeStr = formatDate(dateTime,
              [yyyy, '', mm, '', dd, '', HH, '', nn, '', ss, '', SSS]);
          fileName = '${userNo}_${timeStr}_$index.jpg';
          print(fileName);
        }
        ResultData upRes =
        await CommonNetWork.uploadImg(img, fileName: fileName);

        if (upRes.success) {
          _list.add(upRes.data);
        } else {
          return null;
        }
      } else if (img is AssetEntityFile) {
        if (img.url != null) {
          _list.add(img.url);
        } else {
          if (img.isVideo) {
            DateTime dateTime = DateTime.now();
            ResultData thumbRes = await CommonNetWork.uploadImg(img.thumbFile);
            String timeStr = formatDate(dateTime,
                [yyyy, '', mm, '', dd, '', HH, '', nn, '', ss, '', SSS]);
            String fileName = (userNo == null || userNo.isEmpty)
                ? '${timeStr}_$index.mp4'
                : '${userNo}_${timeStr}_$index.mp4';
            ResultData upRes =
            await CommonNetWork.uploadImg(img.file, fileName: fileName);
            if (thumbRes.success && upRes.success) {
              _list.add('${upRes.data}|${thumbRes.data}');
            } else {
              return null;
            }
          } else {
            String fileName;
            if (userNo != null) {
              DateTime dateTime = DateTime.now();

              String timeStr = formatDate(dateTime,
                  [yyyy, '', mm, '', dd, '', HH, '', nn, '', ss, '', SSS]);
              fileName = '${userNo}_${timeStr}_$index.jpg';
              print(fileName);
            }
            ResultData upRes =
            await CommonNetWork.uploadImg(img.file, fileName: fileName);

            if (upRes.success) {
              _list.add(upRes.data);
            } else {
              return null;
            }
          }
        }
      } else {
        _list.add(img);
      }
      ++index;
    }
    print('--------upload img:$_list');
    return _list;
  }

  ///获取订单参数
  static getConfigOptions({
    String configPlatformId = '0',
  }) async {
    Map pamars = Map();
    var res = await httpTool.netFetch(
      'PatrolOrder/ConfigData?configPlatformId=$configPlatformId',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///添加订单
  static addOrder({
    String planId,
    String userID,
    String communityID,
    String infoJson,
    String orderPhoto,
    String orderSign,
    int orderStatus,
    String checkOrderGasTotal = '0',
    String checkOrderUseGasTotal = '0',
    String checkOrderLeaveGasTotal = '0',
    String orderID,
    String fixContent,
    String fixPhoto,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['scworkId'] = orderID;
    pamars['scworkContent'] = infoJson;
    pamars['scworkAttachment'] = orderPhoto;
    pamars['scworkSignature'] = orderSign;
    pamars['scworkResultstatus'] = orderStatus;
    // pamars['CheckOrderGasTotal'] = checkOrderGasTotal;
    // pamars['CheckOrderUseGasTotal'] = checkOrderUseGasTotal;
    // pamars['CheckOrderLeaveGasTotal'] = checkOrderLeaveGasTotal;
    if (orderStatus == 2) {
      pamars['scworkArepairAfterremark'] = fixContent;
      pamars['scworkArepairAfterattachment'] = fixPhoto;
    }

    var res = await httpTool.staffPost(
      'securitycheck/updateOrder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///添加订单
  static addPatrolOrder({
    String infoJson,
    String orderPhoto,
    String orderSign,
    int orderStatus,
    String orderID,
    String fixContent,
    String fixPhoto,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['ptworkId'] = orderID;
    pamars['ptworkContent'] = infoJson;
    pamars['ptworkAttachment'] = orderPhoto;
    pamars['ptworkSignature'] = orderSign;
    pamars['ptworkResultstatus'] = orderStatus;
    pamars['ptworkStatus'] = 3;
    if (orderStatus == 2) {
      pamars['ptworkArepairremark'] = fixContent;
      pamars['ptworkArepairAfterAttachment'] = fixPhoto;
    }

    var res = await httpTool.staffPost(
      'patrol/workorder/updateworkorder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///订单详情
  static orderDetail(String orderID) async {
    Map pamars = Map();
    pamars['scworkId'] = orderID;
    var res = await httpTool.staffPost(
      'securitycheck/scOrderInfo',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static patrolOrderDetail(String orderID) async {
    Map pamars = Map();
    pamars['ptworkId'] = orderID;
    var res = await httpTool.staffPost(
      'patrol/workorder/detail',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///安检员列表
  static workerList({
    int orderBy,
    String key,
    int page,
    int pageSize = 10,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = 99999;
    pamars['pageIndex'] = page;
    if (key != null) pamars['key'] = key;
    var res = await httpTool.staffPost(
      'securitycheck/xrayStatistics',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static patrolWorkerList({
    int orderBy,
    String key,
    int page,
    int pageSize = 10,
  }) async {
    Map<String, dynamic> pamars = Map();
    // pamars['PageSize'] = 99999;
    // pamars['PageIndex'] = page;
    if (key != null) pamars['key'] = key;
    var res = await httpTool.staffPost(
      'patrol/workorder/worderlistByInspector',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///业主列表
  ///status 1 待安检 2 已安检
  ///
  static checkList(
    String communityID,
    String planID, {
    String waitCheck,
    String key,
    String checkStatus,
    String indoorStatus,
    String scworkBuildingNo,
    int page,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = 10;
    pamars['pageIndex'] = page;
    pamars['scworkTaskcommuntityid'] = communityID;
    pamars['scworkSctaskid'] = planID;
    if (key != null) pamars['appSearch'] = key;
    if (waitCheck != null) pamars['scworkStatus'] = waitCheck;
    if (indoorStatus != null) pamars['scworkDoorstatus'] = indoorStatus;
    if (checkStatus != null) pamars['scworkResultstatus'] = checkStatus;
    if (scworkBuildingNo != null) pamars['scworkBuildingNo'] = scworkBuildingNo;

    var res = await httpTool.staffPost(
      'securitycheck/scWorkOrder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static checkHistoryList(String userNo) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = 100;
    pamars['pageIndex'] = 1;
    pamars['scworkStatus'] = 3;
    pamars['scworkUserNo'] = userNo;
    var res = await httpTool.staffPost(
      'securitycheck/scWorkOrder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///首页信息 安检员
  static mainInfo() async {
    Map<String, dynamic> pamars = Map();
    pamars['sctaskId'] = GlobalStore.store.getState().userInfo.plantID;
    var res = await httpTool.staffPost(
      'securitycheck/scTaskStatistical',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static mainPatrolInfo() async {
    Map<String, dynamic> pamars = Map();
    pamars['ptworkPttaskid'] =
        GlobalStore.store.getState().userInfo.patrolPlantID;
    var res = await httpTool.staffPost(
      'patrol/workorder/workorderByAreaCount',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static mainLeaderInfo() async {
    var res = await httpTool.netFetch(
      'PatrolOrder/leaderindextotal',
      null,
      method: 'get',
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///修改头像
  ///修改头像
  static updateUserHeader(String header) async {
    Map pamars = Map();
    pamars['AdminId'] = GlobalStore.store.getState().userInfo.userid;
    pamars['AdminPhoto'] = header;
    var res = await httpTool.netFetch('Patrol/updateuser', pamars);
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static staffUpdateUserHeader(String header) async {
    Map pamars = Map();
    pamars['userId'] = GlobalStore.store.getState().userInfo.userid;
    pamars['avatar'] = header;
    var res = await httpTool.staffPost('admin/updateAvatar', pamars);
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///修改密码
  static updatePassword(String old, String newWord) async {
    Map pamars = Map();
    pamars['Id'] = GlobalStore.store.getState().userInfo.userid;
    pamars['Pwd'] = newWord;
    pamars['OldPwd'] = old;
    var res = await httpTool.netFetch('appuser/reset_pwd', pamars);
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static staffUpdatePassword(String old, String newWord) async {
    Map pamars = Map();
    pamars['Id'] = GlobalStore.store.getState().userInfo.userid;
    pamars['Pwd'] = newWord;
    pamars['OldPwd'] = old;
    var res = await httpTool.staffPost('admin/resetPwd', pamars);
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixOrderList({
    String workId,
    int status,
    int page,
    int pageSize = 10,
    String type = '2,4,5',
    String key = '',
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = pageSize;
    pamars['pageIndex'] = page;
    if (key.isNotEmpty) pamars['appSearch'] = key;
    if (status != null) pamars['bizStatus'] = status;
    pamars['bizType'] = type;
    var res = await httpTool.staffPost(
      'businessWorkOrder/getBusinessList',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixOrderHistoryList({
    String userNo,
    int status = 0,
    int page,
    int pageSize = 100,
    String type = '2,4',
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = pageSize;
    pamars['pageIndex'] = page;
    pamars['bizResult'] = 1;
    pamars['bizType'] = type;
    pamars['bizUserno'] = userNo;
    var res = await httpTool.staffPost(
      'businessWorkOrder/getBusinessList',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixTransfer(
    String itemID,
    String content,
    // String workerID,
  ) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizTransferreason'] = content;
    pamars['bizId'] = itemID;
    // pamars['bizOrdertakerid'] = workerID;

    var res = await httpTool.staffPost(
      'businessWorkOrder/getTransferBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixGetOrder(String itemID) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizId'] = itemID;

    var res = await httpTool.staffPost(
      'businessWorkOrder/getReceiveBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixOrderAppoint(String itemID) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizId'] = itemID;
    pamars['bizIsAppointment'] = '1';
    var res = await httpTool.staffPost(
      'businessWorkOrder/editBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixRepairOrder(String itemID) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizStatus'] = 4;
    pamars['bizId'] = itemID;

    var res = await httpTool.staffPost(
      'businessWorkOrder/editBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixOrderDetail(String itemID) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizId'] = itemID;

    var res = await httpTool.staffPost(
      'businessWorkOrder/getBusinessDetail',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static materialList(String type) async {
    Map<String, dynamic> pamars = Map();
    pamars['materialType'] = type;

    var res = await httpTool.staffPost(
      'material/list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixOrderSubmit({
    String jsonContent,
    String itemID,
    String signPhoto,
    bool isSolve = true,
    String orderPhoto,
    String bizMeterContent = '',
    bool isSave = false,
    List materList ,
    String type,
    Map extendInfo,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizMaintenanceremark'] = jsonContent;
    pamars['bizId'] = itemID;
    if (materList != null) {
      pamars['businessMaterialRelList'] = materList;
    }
    pamars['bizSignature'] = signPhoto;
    pamars['bizStatus'] = isSave ? 4 : 5;
    if (isSolve != null) pamars['bizResult'] = isSolve ? 1 : 0;
    pamars['bizMaintenancefiles'] = orderPhoto;
    pamars['bizMetercontent'] = bizMeterContent;
    pamars['bizType'] = type;
    pamars['securitycheckBusinessExtend'] = extendInfo;
    var res = await httpTool.staffPost(
      'businessWorkOrder/editBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixMainInfo(String userID, {String type = '2,4,5'}) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizType'] = type;
    var res = await httpTool.staffPost(
      'businessWorkOrder/getBusinessStatusNum',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static safeCountInfo() async {
    Map<String, dynamic> pamars = Map();
    var res = await httpTool.staffPost(
      'securitycheck/scStatistics',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static fixCountInfo() async {
    Map<String, dynamic> pamars = Map();
    var res = await httpTool.staffPost(
      'businessWorkOrder/getBusinessNumForLeader',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static patrolCountInfo() async {
    Map<String, dynamic> pamars = Map();
    var res = await httpTool.staffPost(
      'patrol/workorder/workorderByLeaderCount',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static countTotalInfo() async {
    var res = await httpTool.netFetch(
      'StaticReport/order_total',
      null,
      method: 'get',
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static orderPayType() async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 10;
    pamars['PageIndex'] = 1;
    Map<String, dynamic> sub = Map();
    sub['TypeStatus'] = 1;
    pamars['Params'] = sub;
    var res = await httpTool.netFetch(
      'appuser/paytype',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getCommunityList(int page, {String key = ''}) async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 20;
    pamars['PageIndex'] = page;
    Map<String, dynamic> sub = Map();
    sub['CommunityStatus'] = -1;
    sub['CommunityName'] = key;
    pamars['Params'] = sub;
    var res = await httpTool.netFetch(
      'community/list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static addInstallUser({
    String userName,
    String phone,
    String address,
    String communityID,
    String communityName,
    String payType,
    String money,
    String idCard = '',
    String photo = '',
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['OtherpayUsername'] = userName;
    pamars['OtherpayUsermobile'] = phone;
    pamars['OtherpayUserAddress'] = address;
    pamars['OtherpayUserIDCard'] = idCard;
    if (photo.length != 0) pamars['OtherpayPhoto'] = photo;
    pamars['OtherpayInCommunity'] = communityName;
    pamars['OtherpayInCommunityId'] = communityID;
    pamars['OtherpayPaytype'] = payType;
    pamars['OtherpayPayment'] = money;
    var res = await httpTool.netFetch(
      'OtherPayLog/add_newuser',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getSystemInstallInfo() async {
    Map<String, dynamic> pamars = Map();
    pamars['ConfigPlatformId'] = ThemeConfig.platFormId;
    pamars['ConfigKey'] = '是否收费配置';
    var res = await httpTool.netFetch(
      'sysconfig/list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getInstallList(int page, {String key = ''}) async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 10;
    pamars['PageIndex'] = page;
    Map<String, dynamic> sub = Map();
    sub['Keys'] = key;
    sub['OtherpayPlatformid'] = ThemeConfig.platFormId;
    pamars['Params'] = sub;
    var res = await httpTool.netFetch(
      'OtherPayLog/list_app',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static installDetailView(String itemID) async {
    var res = await httpTool.netFetch(
      'OtherPayLog/info?id=$itemID',
      null,
      method: 'get',
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getInstallMainInfo() async {
    var res = await httpTool.netFetch(
      'OtherPayLog/app_static?adminId=${GlobalStore.store.getState().userInfo.userid}',
      null,
      method: 'get',
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static setIndoorStatus(String checkorderId,
      {String reason = '',
      String communityID,
      String status,
      String userID,
      String imgs = ''}) async {
    Map<String, dynamic> pamars = Map();
    pamars['scworkContent'] = reason;
    pamars['scworkDoorstatus'] = status;
    pamars['scworkId'] = checkorderId;
    if (imgs.length != 0) pamars['scworkAttachment'] = imgs;

    var res = await httpTool.staffPost(
      'securitycheck/updateOrder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static delCheckOrder(String itemID) async {
    Map<String, dynamic> pamars = Map();
    pamars['scworkId'] = itemID;
    var res = await httpTool.staffPost(
      'securitycheck/deletOrder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static delPatrolOrder(String itemID) async {
    Map<String, dynamic> pamars = Map();
    pamars['ptworkId'] = itemID;
    var res = await httpTool.staffPost(
      'patrol/workorder/deleteOrder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static editUserPhone(
      {String userID, String userName, String userPhone}) async {
    Map<String, dynamic> pamars = Map();
    pamars['UserId'] = userID;
    pamars['UserName'] = userName;
    pamars['UserMobile'] = userPhone;
    var res = await httpTool.netFetch(
      'PatrolOrder/modify_username',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///添加订单
  static addFixOrder({
    String userID,
    String accountName,
    String accountAddress,
    String accountMobile,
    String accountNo,
    String communityName,
    String communityID,
    String content,
    String checkOrderID,
    String contentPhoto,
    String photo = '',
    String contentJson = '',
  }) async {
    Map<String, dynamic> pamars = Map();

    pamars['WorderUserid'] = userID;
    pamars['WorderUsername'] = accountName;
    pamars['WorderUseraddress'] = accountAddress;
    pamars['WorderUsermobile'] = accountMobile;
    pamars['WorderUserno'] = accountNo;
    pamars['WorderIncommunity'] = communityName;
    pamars['WorderIncommunityid'] = communityID;
    pamars['WorderContent'] = content;
    pamars['WorderType'] = 3;
    pamars['WOrderSubjectId'] = checkOrderID;
    pamars['WorderPlatformid'] = ThemeConfig.platFormId;
    pamars['WOrderFinishContentJson'] = contentJson;

    if (photo.length != 0) pamars['WOrderContentPhoto'] = photo;

    var res = await httpTool.netFetch(
      'OrderWork/add_workerorder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getPlantList() async {
    var res = await httpTool.netFetch(
      'PatrolOrder/planlist?userId=${GlobalStore.store.getState().userInfo.userid}',
      null,
      method: 'get',
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static versionCheck() async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 10;
    pamars['PageIndex'] = 1;
    Map<String, dynamic> sub = Map();
    sub['VerPlatformType'] = Platform.isAndroid ? 1 : 3;
    sub['VerAppType'] = 2;
    pamars['Params'] = sub;
    var res = await httpTool.netFetch(
      'appverlog/list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///新版本
  static userRegister(String mobile, String password) async {
    Map<String, dynamic> pamars = Map();
    pamars['AppUserPwd'] = password;
    pamars['AppUserMobile'] = mobile;

    var res = await httpTool.netFetch(
      'appuser/register',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///gas用户添加接口
  static gasNoBlind({String userName, String accountNo}) async {
    Map<String, dynamic> pamars = Map();
    pamars['BindUserName'] = userName;
    pamars['BindUserNo'] = accountNo;
    pamars['BindAppUserId'] = GlobalStore.store.getState().userInfo.userid;
    pamars['BindPlatformid'] = ThemeConfig.platFormId;

    var res = await httpTool.netFetch(
      'appbind/add_bind',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static gasAccountSearch({
    String userName = '',
    String userMobile = '',
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['UserName'] = userName;
    pamars['UserMobile'] = userMobile;

    var res = await httpTool.netFetch(
      'wx/search_no',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static delBlind(String bindID, String accountNo) async {
    Map<String, dynamic> pamars = Map();
    pamars['BindId'] = bindID;
    pamars['BindAppUserId'] = GlobalStore.store.getState().userInfo.userid;
    pamars['BindPlatformid'] = ThemeConfig.platFormId;
    pamars['BindUserNo'] = accountNo;
    var res = await httpTool.netFetch(
      'appbind/del_bind',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getGasNoBlindList({int page = 1}) async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 100;
    pamars['PageIndex'] = page;
    Map<String, dynamic> sub = Map();
    sub['BindPlatformid'] = ThemeConfig.platFormId;
    sub['BindAppUserId'] = GlobalStore.store.getState().userInfo.userid;

    pamars['Params'] = sub;

    var res = await httpTool.netFetch(
      'appbind/bind_list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static safeOrderDetail(String accountNo) async {
    var res = await httpTool.netFetch(
      'appwork/last_patroloder?userNo=$accountNo',
      null,
      method: 'get',
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static addWorkOrder({
    String photo = '',
    String addTime = '',
    String gasFactory = '',
    String content = '',
    String communityID = '',
    String communityName = '',
    String accountNo = '',
    String gasNo = '',
    String accountMobile = '',
    String accountAddress = '',
    String accountName = '',
    String accountID = '',
    String accountType = '2',
  }) async {
    Map<String, dynamic> pamars = Map();
    if (photo.length != 0) pamars['bizFiles'] = photo;
    pamars['bizDispatchtime'] = addTime;
    pamars['bizContent'] = content;
    // pamars['WorderIncommunity'] = communityName;
    // pamars['WorderIncommunityid'] = communityID;
    // pamars['WOrderMeterFactory'] = gasFactory;
    //
    // pamars['WorderUserno'] = accountNo;
    // pamars['WorderMeterno'] = gasNo;
    pamars['bizUsertel '] = accountMobile;
    pamars['bizAddress'] = accountAddress;
    pamars['bizUsername'] = accountName;

    pamars['bizUserid'] = accountID;
    // pamars['WorderType'] = accountType;
    // pamars['WorderPlatformid'] = ThemeConfig.platFormId;

    var res = await httpTool.staffPost(
      'reservation/add',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getWorkUserInfo({
    String accountNo = '',
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['UserNo'] = accountNo;

    var res = await httpTool.netFetch(
      'appwork/user_info',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static gasAccountInfo({
    String userName = '',
    String accountNo = '',
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['UserName'] = userName;
    pamars['UserNo'] = accountNo;
    pamars['SearchType'] = 1;

    var res = await httpTool.netFetch(
      'appbind/user_info',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static orderList({String orderTime, int page}) async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 10;
    pamars['PageIndex'] = page;
    Map<String, dynamic> sub = Map();
    sub['Date'] = orderTime;

    pamars['Params'] = sub;
    var res = await httpTool.netFetch(
      'appuser/order_list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static feedBackAdd(String content, String mobile) async {
    Map<String, dynamic> pamars = Map();
    pamars['OpUserId'] = GlobalStore.store.getState().userInfo.userid;
    pamars['OpUserName'] = GlobalStore.store.getState().userInfo.nickname;
    pamars['OpUserMobile'] = mobile;
    pamars['OpContent'] = content;
    var res = await httpTool.netFetch(
      'appsiteopinion/add',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static setUserInfo({String nickName, bool sex, String header}) async {
    Map<String, dynamic> pamars = Map();
    pamars['AppUserId'] = GlobalStore.store.getState().userInfo.userid;
    pamars['AppUserPhoto'] = header;
    pamars['AppUserSex'] = sex;
    pamars['AppUserNickName'] = nickName;

    var res = await httpTool.netFetch(
      'appuser/update',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static bindBluetooth(String userNo, String blueToothNo) async {
    Map<String, dynamic> pamars = Map();
    pamars['BluetoothBindUserNo'] = userNo;
    pamars['BluetoothNo'] = blueToothNo;

    var res = await httpTool.netFetch(
      'bluetooth/bind',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getBindBluetoothStatus(String userNo) async {
    Map<String, dynamic> pamars = Map();
    pamars['BluetoothBindUserNo'] = userNo;

    var res = await httpTool.netFetch(
      'bluetooth/query_state',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static submitPay(String userNo, String mountFee, {String openID = ''}) async {
    Map<String, dynamic> pamars = Map();
    pamars['UserNo'] = userNo;
    pamars['UAmountFee'] = mountFee;
    pamars['Openid'] = openID;
    var res = await httpTool.netFetch(
      'bluetooth/submit_pay',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static queryOrderStatus(String orderNo, String tranNo) async {
    Map<String, dynamic> pamars = Map();
    pamars['OrderNo'] = orderNo;
    pamars['ThirdCode'] = tranNo;
    var res = await httpTool.netFetch(
      'bluetooth/query_order_state',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getCardMemo(String userID) async {
    Map<String, dynamic> pamars = Map();
    var res = await httpTool.netFetch('appuser/cardmemo?userId=$userID', pamars,
        method: 'get');
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getQCCardMemo(String userId) async {
    Map<String, dynamic> pamars = Map();
    pamars['user_code'] = userId;
    var res = await httpTool.netFetch(
      'gasGasOrder/GetQcMeterInfoByCardNo',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///获取系统配置
  static getSystemConfig() async {
    Map<String, dynamic> pamars = Map();
    pamars['PageSize'] = 10;
    pamars['PageIndex'] = 1;
    Map<String, dynamic> params = Map();
    params['ConfigKey'] = 'AppInfo';
    pamars['Params'] = params;

    var res = await httpTool.netFetch(
      'sysconfig/list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static nbUserInfo(String userID) async {
    Map<String, dynamic> pamars = Map();
    Map<String, dynamic> params = Map();
    params['UserId'] = userID;
    params['UserBusiId'] = [];
    params['UserStatus'] = '';
    params['IsArrears'] = -1;
    params['IsLateFee'] = -1;

    pamars['PageSize'] = 10;
    pamars['PageIndex'] = 1;
    pamars['Params'] = params;
    var res = await httpTool.netFetch(
      'userinfo/iot_list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static nbUserBillList({
    String userID,
    String startTime,
    String endTime,
    int page = 1,
  }) async {
    Map<String, dynamic> pamars = Map();
    Map<String, dynamic> params = Map();
    params['BillUserId'] = userID;
    params['BillStartTime'] = startTime ?? '';
    params['BillEndTime'] = endTime ?? '';

    pamars['PageSize'] = 10;
    pamars['PageIndex'] = page;
    pamars['Params'] = params;
    var res = await httpTool.netFetch(
      'order/iot_bill_list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static machineUserInfo(String userID) async {
    Map<String, dynamic> pamars = Map();
    Map<String, dynamic> params = Map();
    params['UserId'] = userID;
    params['UserNo'] = '';
    params['UserName'] = '';
    params['UserMobile'] = '';
    params['UserStatus'] = '';
    params['UserInCommunityId'] = 0;
    params['UserLabelId'] = 0;
    params['UserBusiId'] = 0;
    params['GasMeterNo'] = '';
    params['GasUsedType'] = 0;
    params['GasUserType'] = 0;
    params['GasUsedStatus'] = 0;
    params['GasMeterType'] = '';
    params['IsArrears'] = -1;
    params['IsLateFee'] = -1;
    params['UserBusiId'] = [];

    pamars['PageSize'] = 10;
    pamars['PageIndex'] = 1;
    pamars['Params'] = params;
    var res = await httpTool.netFetch(
      'userinfo/mach_list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static machineUserBillList({
    String userID,
    String startTime,
    String endTime,
    int page = 1,
  }) async {
    Map<String, dynamic> pamars = Map();
    Map<String, dynamic> params = Map();
    params['BillUserId'] = userID;
    params['BillStartTime'] = startTime ?? '';
    params['BillEndTime'] = endTime ?? '';
    params['BillPlatformId'] = '';

    pamars['PageSize'] = 10;
    pamars['PageIndex'] = page;
    pamars['Params'] = params;
    var res = await httpTool.netFetch(
      'order/bill_list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getOssInfo() async {
    Map<String, dynamic> pamars = Map();
    var res = await httpTool.netFetch('sysconfig/ali_oss_bucket', pamars,
        method: 'Get');
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static staffUserLogin(
    String mobile,
    String password,
    String roleName,
  ) async {
    Map<String, dynamic> pamars = Map();
    pamars['password'] = password;
    pamars['username'] = mobile;
    pamars['rolename'] = roleName;
    var res = await httpTool.staffPost(
      'login',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static staffCheckPlans(
      {int page = 1, int pageSize = 9999, String token}) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = pageSize;
    pamars['pageIndex'] = page;
    var res = await httpTool.staffPost(
      'securitycheck/scTask',
      pamars,
      header: token != null ? {'token': token} : null,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static staffPatrolPlans(
      {int page = 1, int pageSize = 9999, String token}) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = pageSize;
    pamars['pageIndex'] = page;
    var res = await httpTool.staffPost(
      'patrol/task/list',
      pamars,
      header: token != null ? {'token': token} : null,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///安检小区列表
  ///小区列表
  ///status 1 待执行 2 执行中 3 已完成
  static communityList({
    int status = 1,
    String key,
    String plantID,
    String userID,
    int page,
    int pageSize = 99999,
  }) async {
    Map<String, dynamic> pamars = Map();
    String currentID = plantID ?? GlobalStore.store.getState().userInfo.plantID;
    String currentUserID =
        userID ?? GlobalStore.store.getState().userInfo.userid;
    if (currentID != null) pamars['communtitySctaskid'] = currentID;
    if (currentUserID != null)
      pamars['communtitySecurityInspectorIds'] = currentUserID;
    if (status != 0) pamars['communtityStatus'] = status;
    if (key != null) pamars['communtityCommuntityname'] = key;
    pamars['pageSize'] = pageSize;
    pamars['pageIndex'] = page;

    var res = await httpTool.staffPost(
      'securitycheck/scCommuntity',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///巡检片区列表
  ///status 1 待执行 2 执行中 3 已完成
  static patrolAreaList({
    int status = 1,
    String key,
    String plantID,
    int page = 1,
    int pageSize = 99999,
    String userID,
  }) async {
    Map<String, dynamic> pamars = Map();
    String currentID =
        plantID ?? GlobalStore.store.getState().userInfo.patrolPlantID;
    if (currentID != null) pamars['ptareaPttaskid'] = currentID;
    if (status != 0) pamars['ptareaStatus'] = status;
    if (key != null) pamars['ptareaAreaname'] = key;
    if (userID != null) pamars['communtitySecurityInspectorIds'] = userID;
    pamars['pageSize'] = pageSize;
    pamars['pageIndex'] = page;
    var res = await httpTool.staffPost(
      'patrol/taskArea/list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///获取安检项
  static staffCheckConfig(
      {int worktplType = 1, String worktplUsertype = '1'}) async {
    Map<String, dynamic> pamars = Map();
    pamars['worktplType'] = worktplType;
    pamars['worktplUsertype'] = worktplUsertype;

    var res = await httpTool.staffPost(
      'workorderTpl/detail',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///巡检工单列表
  ///业主列表
  ///
  static patrolItemList(
    String areaID,
    String planID, {
    String waitCheck,
    String key,
    String checkStatus,
    int page,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = 10;
    pamars['pageIndex'] = page;
    pamars['ptworkPttaskAreaId'] = areaID;
    pamars['ptworkPttaskid'] = planID;
    if (key != null) pamars['ptworkPointname'] = key;
    if (waitCheck != null) pamars['ptworkStatus'] = waitCheck;
    if (checkStatus != null) pamars['ptworkResultstatus'] = checkStatus;

    var res = await httpTool.staffPost(
      'patrol/workorder/list',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///设置巡检工单状态
  static staffPatrolStatus({
    int workStatus,
    String signImage,
    String reasonContent,
    String reasonImage,
    String orderID,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['ptworkStatus'] = workStatus;
    pamars['ptworkId'] = orderID;

    if (workStatus == 2) {
      pamars['ptworkSignin'] = signImage;
    } else if (workStatus == 4) {
      pamars['ptworkContent'] = reasonContent;
      pamars['ptworkAttachment'] = reasonImage;
    }

    var res = await httpTool.staffPost(
      'patrol/workorder/updateworkorder',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  ///维修员工列表
  static staffFixWorkerList() async {
    Map<String, dynamic> pamars = Map();

    var res = await httpTool.staffPost(
      'businessWorkOrder/getRepairpersonnel',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static userDel(String userID) async {
    Map<String, dynamic> pamars = Map();
    pamars['AppUserId'] = userID;

    var res = await httpTool.netFetch(
      'appuser/del',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static engineerOrderReset(String itemID) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizId'] = itemID;

    var res = await httpTool.staffPost(
      'businessWorkOrder/sendOrderAgain',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static getMeterConfig() async {
    var res = await httpTool.netFetch(
      'sysconfig/select_list?configKeys=%E8%A1%A8%E5%85%B7%E5%8E%82%E5%AE%B6,%E5%8D%A1%E8%A1%A8%E6%8E%A7%E5%88%B6%E5%99%A8',
      null,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static engineerEditInstallType(String type, String itemId) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizAppliancetype'] = type;
    pamars['bizId'] = itemId;
    var res = await httpTool.staffPost(
      'businessWorkOrder/editBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static engineerFireOrderContent({String itemId,String imageInfo,String remark}) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizStatus'] = 9;
    pamars['bizId'] = itemId;
    pamars['bizType'] = '6';
    Map<String, dynamic> subInfo = Map();
    subInfo['remark'] = remark;
    subInfo['imgInfo'] = imageInfo;
    pamars['securitycheckBusinessExtend'] = subInfo;
    var res = await httpTool.staffPost(
      'businessWorkOrder/editBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static engineerOrderFix(String itemID,
      {int status, String content, bool isSolve}) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizStatus'] = status;
    pamars['bizId'] = itemID;
    pamars['bizMaintenanceremark'] = content;
    if (isSolve != null) {
      pamars['bizResult'] = isSolve ? 1 : 0;
    }

    var res = await httpTool.staffPost(
      'businessWorkOrder/editBusiness',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static addMeter({
    String meterBiaoxiang,
    String meterBaseVolume,
    String meterType,
    String meterInstallType,
    String meterNo,
    String meterMemo,
    String meterId,
    int isClosed = 0,
    String meterFengNumber = '',
    String meterFactory,
    String meterUnitType,
    String meterSpecs,
    String meterCtrlCode,
    int meterFeeMode = 1,
    String userIdNo,
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['MeterPlatformId'] = ThemeConfig.platFormId;
    pamars['MeterOperateName'] = GlobalStore.store.getState().userInfo.nickname;
    pamars['MeterOperateId'] = GlobalStore.store.getState().userInfo.userid;
    pamars['MeterBaseVolume'] = meterBaseVolume;
    pamars['MeterMaxBuyGas'] = 99999;
    pamars['MeterIsDelete'] = false;
    pamars['MeterStatus'] = 2;
    pamars['MeterUseStatus'] = 0;
    pamars['MeterType'] = meterType;
    pamars['MeterFeeMode'] = meterFeeMode;
    pamars['MeterSerHallId'] = 0;
    pamars['MeterSerHallName'] = '';
    pamars['MeterInstallType'] = meterInstallType;
    pamars['MeterBiaoxiang'] = meterBiaoxiang;
    pamars['MeterMemo'] = meterMemo;
    pamars['MeterNo'] = meterNo;
    pamars['MeterId'] = meterId == null ? '0' : meterId;
    pamars['MeterIsJiaFeng'] = isClosed;
    pamars['MeterFengNumber'] = meterFengNumber;
    pamars['MeterFactory'] = meterFactory;
    pamars['MeterUnitType'] = meterUnitType;
    pamars['MeterSpecs'] = meterSpecs;
    pamars['MeterCtrlCode'] = meterCtrlCode;
    pamars['MeterUserCardId'] = userIdNo;

    var res = await httpTool.netFetch(
      'meter/add',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static engineerMainInfo(String userID, {String type = '1'}) async {
    Map<String, dynamic> pamars = Map();
    pamars['bizType'] = type;
    var res = await httpTool.staffPost(
      'businessWorkOrder/getBusinessStatusNum',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }

  static engineerOrderList({
    String workId,
    int status,
    int page,
    int pageSize = 10,
    String type = '1,7',
    String key = '',
  }) async {
    Map<String, dynamic> pamars = Map();
    pamars['pageSize'] = pageSize;
    pamars['pageIndex'] = page;
    if (status != null) pamars['bizStatus'] =  status;
    pamars['bizType'] = type;
    if (key.isNotEmpty) pamars['appSearch'] = key;
    var res = await httpTool.staffPost(
      'businessWorkOrder/getBusinessList',
      pamars,
    );
    if (res is DioError) {
      DioError err = res;
      return ResultData(null, false, -1, err.message);
    } else {
      return ResultData(res, true, 0, "登录成功！");
    }
  }
}
